<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title> - 登录</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico"> <link href="../css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="../css/font-awesome.css?v=4.4.0" rel="stylesheet">

    <link href="../css/animate.css" rel="stylesheet">
    <link href="../css/style.css?v=4.1.0" rel="stylesheet">
    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->
    <script>if(window.top !== window.self){ window.top.location = window.location;}</script>
</head>

<body class="gray-bg">

    <div class="middle-box text-center loginscreen  animated fadeInDown">
        <div>
            <div>

                <h1 class="logo-name">K</h1>

            </div>
            <h3>请输入设备Key</h3>

            <form class="m-t" id="appForm" role="form" action="./factory/updateApp" method="post">
                <input type="text" hidden="hidden" id="bagBelong" name="bagBelong" value="#(bagBelong)">
                #for(x:devices)
                <div class="form-group">
                    <input class="form-control" placeholder="#(x.name)" id="#(x.name)" name="#(x.name)" required="">
                </div>
                #end
                <button type="button"  onclick="mysubmmit()" class="btn btn-primary block full-width m-b" id="start">提  交</button>

            </form>
        </div>
    </div>

    <!-- 全局js -->
    <script src="../js/jquery.min.js?v=2.1.4"></script>
    <script src="../js/bootstrap.min.js?v=3.3.6"></script>

    <!-- 自定义js -->
    <script src="../js/content.js?v=1.0.0"></script>


    <!-- Steps -->
    <script src="../js/plugins/staps/jquery.steps.min.js"></script>

    <!-- Jquery Validate -->
    <script src="../js/plugins/validate/jquery.validate.min.js"></script>
    <script src="../js/plugins/validate/messages_zh.min.js"></script>

    <script>
        function mysubmmit(){
            $.ajax({
                type: "GET",
                url: "/factory/updateApp",
                data: $('#appForm').serialize(),
                dataType: "json",//预期服务器返回的数据类型
                success: function (result) {
                    console.log(result);
                    if(result.state == "OK"){
                        alert("添加应用成功，刷新页面可以看到");
                        location.reload(true);
                    }else{
                        if(result.error=="error"){
                            alert(result.msg);
                        }else{
                            alert(result.msg);
                        }
                    }
                },
                error: function (err) {
                }
            });
        };
    </script>
    

</body>

</html>
